package com.zxc.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.zxc.common.utils.R;
import com.zxc.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping(value = "/memberOrder.html")
    public String orderMemberPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, Model model){
        //我们可以获取到支付宝给我们发送的很多的参数
        //request 验证签名


        //查出当前登录的用户的所有的订单数据
        Map<String,Object> map = new HashMap<>();
        map.put("page",pageNum);
        R r = orderFeignService.listWithItem(map);
        System.out.println(JSON.toJSONString(r));
        model.addAttribute("orders",r);
        return "orderList";
    }
}
